<?php

	// TITLE: Committee_attendance AUTO MODEL
	// FILE: scaffolding/model/committee_attendance.php
	// AUTHOR: AUTOGEN
	// CREATED: 2015/04/20 07:49:57
	// DESCRIPTION: 
	// REQUIREMENTS: 

	$createCommitteeAttendance = function($con, $committeeAttendance) {
		$sql = 'INSERT INTO committee_attendance (id, committee_id, volunteer_id, status, date) VALUES (';
		$sql .= $committee_attendance->getId() . ', ';
		$sql .= $committee_attendance->getCommitteeId() . ', ';
		$sql .= $committee_attendance->getVolunteerId() . ', ';
		$sql .= $committee_attendance->getStatus() . ', ';
		$sql .= $committee_attendance->getDate() . ')';
		$sql .= ')';
		$result = mysqli_query($con, $sql);
		$id = ($result) ? mysqli_insert_id($con) : $result;
		mysqli_close($con);
		return $id;
	};

	$readCommitteeAttendance = function($con, $id) {
		$sql = 'SELECT * FROM committee_attendance WHERE id = ' . $id;
		$results = mysqli_query($con, $sql);
		mysqli_close($con);
		if ($results) {
			$result = mysqli_fetch_array($results);
			$committeeAttendance = new CommitteeAttendance();
			$committeeAttendance->setId(result[0]);
			$committeeAttendance->setCommitteeId($dbio->select($readCommittee(result[1])));
			$committeeAttendance->setVolunteerId($dbio->select($readVolunteer(result[2])));
			$committeeAttendance->setStatus(result[3]);
			$committeeAttendance->setDate(result[4]);
		} else {
			$committeeAttendance = false;
		}
		return $committeeAttendance;
	};

	$updateCommitteeAttendance = function($con, $committeeAttendance) {
		$sql = 'UPDATE committee_attendance SET ';
		$sql .= 'id = ' . $committee_attendance->getId() . ', ';
		$sql .= 'committee_id = ' . $committee_attendance->getCommitteeId() . ', ';
		$sql .= 'volunteer_id = ' . $committee_attendance->getVolunteerId() . ', ';
		$sql .= 'status = ' . $committee_attendance->getStatus() . ', ';
		$sql .= 'date = ' . $committee_attendance->getDate() ;
		$sql .= 'WHERE id = ' . id;
		$result = mysqli_query($con, $sql);
		mysqli_close($con);
		return $result;
	};

	$deleteCommitteeAttendance = function($con, $id) {
		$sql = 'DELETE FROM committee_attendance WHERE id = ' . $id;
		$result = mysqli_query($con, $sql);
		mysqli_close($con);
		return $result;
	};

	$listCommitteeAttendance = function($con) {
		$sql = 'SELECT * FROM committee_attendance';
		$results = mysqli_query($con, $sql);
		mysqli_close($con);
		if ($results) {
			$committeeAttendances = array();
			while ($result = mysqli_fetch_array($results)) {
				$committeeAttendance = new CommitteeAttendance();
				$committeeAttendance->setId(result[0]);
				$committeeAttendance->setCommitteeId($dbio->select($readCommittee(result[1])));
				$committeeAttendance->setVolunteerId($dbio->select($readVolunteer(result[2])));
				$committeeAttendance->setStatus(result[3]);
				$committeeAttendance->setDate(result[4]);
				$committeeAttendances[] = committeeAttendance;
			}// end while
		} else {
			$committeeAttendances = false;
		}
		return $committeeAttendances;
	};

